package com.lbs.jiepiaisi.utils;

/**
 *
 * 时间：2017/6/29 19:59
 * 作用：按钮工具类，防止按钮点击过快
 */

public class ButtonUtil {

    // 两次点击按钮之间的点击间隔不能少于1000毫秒
    private static final int MIN_CLICK_DELAY_TIME = 1000;

    private static long lastClickTime;

    public static boolean isFastClick() {
        boolean flag = false;
        long curClickTime = System.currentTimeMillis();
        if ((curClickTime - lastClickTime) >= MIN_CLICK_DELAY_TIME) {
            flag = true;
        }
        lastClickTime = curClickTime;
        return flag;
    }

}
/**
 用法：

 btn.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        if (ButtonUtil.isFastClick()) {
        // 进行点击事件后的逻辑操作
        }
    }
});

 */
